//包含N个接口请求函数的模块
//函数的返回值：promise对象

//[4、根据经纬度和关键字搜索商铺列表](#4根据经纬度和关键字搜索商铺列表)<br/>
//[5、获取一次性验证码](#5获取一次性验证码)<br/>
//[6、用户名密码登陆](#6用户名密码登陆)<br/>
//[7、发送短信验证码](#7发送短信验证码)<br/>
//[8、手机号验证码登陆](#8手机号验证码登陆)<br/>
//[9、根据会话获取用户信息](#9根据会话获取用户信息)<br/>
//[10、用户登出](#10用户登出)<br/>

import ajax from './ajax'

const BASE_URL = '/api'
//根据经纬度获取位置详情 箭头函数
export const reqAddress = (geohash) => ajax(`${BASE_URL}/position/${geohash}`)
// export const reqAddress = (geohash) => ajax(`/position/`, {geohash})
//获取食品分类列表
export const reqFoodTypes = () => ajax(`${BASE_URL}/index_category`)
//根据经纬度获取商铺列表
export const reqShops = (latitude, longitude) => ajax(`${BASE_URL}/shops`, {latitude, longitude})
// export const reqShops = (a, b) => ajax(`${BASE_URL}/shops`, {latitude: a, longitude: b})
// export const reqShops = ({latitude, longitude}) => ajax(`${BASE_URL}/shops`, {latitude, longitude})
//根据经纬度和关键字搜索商铺列表
export const reqSearchShop = (geohash, keyword) => ajax(`${BASE_URL}/search_shops`, {geohash, keyword})
//用户名密码登陆
export const reqPwdLogin = ({name, pwd, captcha}) => ajax(`${BASE_URL}/login_pwd`, {name, pwd, captcha}, 'POST')
//发送短信验证码
export const reqSendCode = (phone) => ajax(`${BASE_URL}/sendcode`, {phone})
//手机号验证码登陆
export const reqSmsCode = (phone, code) => ajax(`${BASE_URL}/login_sms`, {phone, code}, 'POST')
//根据会话获取用户信息
export const reqUserInfo = () => ajax(`${BASE_URL}/userinfo`)
//用户登出
export const reqLogout = () => ajax(`${BASE_URL}/logout`)


/**
 * 获取商家信息
 */
export const reqShopInfo = () => ajax('/info')

/**
 * 获取商家评价数组
 */
export const reqShopRatings = () => ajax('/ratings')

/**
 * 获取商家商品数组
 */
export const reqShopGoods = () => ajax('/goods')


